<template>
  <el-container class="home-container">
    <!-- 侧栏区域 -->
    <el-aside width="200">
      <h1 class="logo" style="height: 70px">航海家</h1>
      <subMenu></subMenu>
    </el-aside>

    <!-- 主题区域 -->
    <el-container>
      <!-- 主题头部区域 -->
      <el-header>
        <el-row type="flex" class="row-bg" justify="space-between">
          <el-col :span="6">
            <div class="grid-content shouqi" @click="collapse">
              <i :class="menuCollapseIcon"></i>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content title">
              <h1>帆船俱乐部</h1>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content info">
              <el-avatar :size="50" :src="avatarUrl"></el-avatar>
              <b class="nickname">{{ userInfo.nickname }}</b>
              <a href="javascript:;" class="esc" @click="esc">退出</a>
            </div>
          </el-col>
        </el-row>
      </el-header>

      <!-- 主题内容区域 -->
      <el-main>
        <div class="nav">
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item v-for="item in breadCrumb" :key="item.name" :to="{name:item.name}">{{item.meta.name}}</el-breadcrumb-item>
           
          </el-breadcrumb>
        </div>

        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
// import {getLoginLogApi} from "../../api"
import * as api from "../../api"; //引入所有的api
// import {mapState,mapActions} from "vuex"   //引入
import { mapState } from "vuex"; //引入
import subMenu from "../../components/SubMenu";
// import recursionRouters from "../../utils/recursionRouters"  //调试用
// import allRouters from "../../router/allRouters"   //调试用
export default {
  components: {
    subMenu,
  },
  methods: {
    //  ...mapActions(["FETCH_MENU_LIST"]),
    esc() {
      //退出页面  并跳转到主页
      this.$router.push("/login");
      //  localStorage中app-token
      localStorage.removeItem("app-token");
      location.reload();
    },
    collapse() {
      this.$store.commit("SET_MENU_COLLAPSE");
    },
  },
  mounted() {
    //  getLoginLogApi()
    //   .then(res=>{  //获取日志
    //     // console.log(res);
    //   })
    // api.getMenuLisyApi()
    //   .then(res=>{
    //     // console.log(res);
    // console.log( recursionRouters(allRouters,res.data.menuList));
    //   })
    // console.log(api);
    //  this.FETCH_MENU_LIST()  //调试
  },
  computed: {
    ...mapState(["userInfo", "menuCollapse","breadCrumb"]),
    avatarUrl() {
      return this.userInfo.headimgurl
        ? this.userInfo.headimgurl
        : "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png";
    },
    menuCollapseIcon() {
      return this.menuCollapse ? "el-icon-s-unfold" : "el-icon-s-fold";
    },
  },
  data() {
    return {};
  },
};
</script>
<style scoped lang="less">
.el-header {
  padding: 0;
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: left;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  // line-height: 160px;
}

//头部区域
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}

.shouqi {
  //   background: #d3dce6;
  cursor: pointer;
  text-align: left;
  .el-icon-s-unfold,
  .el-icon-s-fold {
    font-size: 40px;
  }
}
.el-avatar--circle {
  //   background: #d3dce6;
  vertical-align: middle;
}
.nickname {
  margin: 0 10px;
}
.title {
  //   background: #e5e9f2;
  h1 {
    line-height: 40px;
    font-size: 26px;
    //   color: dodgerblue;
    letter-spacing: 5px;
  }
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
& /deep/.logo {
  background: url(../../assets/imgs/shui.png) no-repeat center;
  background-size: 127% 218%;
  text-align: center;
  letter-spacing: 2px;
  color: #7287a3;
  line-height: 30px;
 
}
</style>